from datetime import datetime

from pydantic import Field
from typing import Optional, Annotated, List

from ...base import BaseApiListOut, BaseSchema, BaseApiOut


class TenantDomainBase(BaseSchema):
    code: Optional[str] = Field(None, description='商户编码')
    brand_id: Optional[int] = Field(None, description='品牌编码')
    domain: Optional[str] = Field(None, description='域名')
    type: Optional[int] = Field(None, description='域名类型 1 A解析 2 CNAME解析')
    is_default: Optional[int] = Field(None, description='默认跳转域名 0普通域名 1默认域名')
    status: Optional[int] = Field(None, description='状态 0未启用 1已启用 2已禁用 3已删除')
    deploy_status: Optional[int] = Field(None, description='域名部署状态 0未部署 1已部署 2已禁用')


class TenantDomainCreate(TenantDomainBase):
    pass


class TenantDomain(TenantDomainBase):
    id: Optional[int] = Field(0, description='自增ID')

    ssl_pem: Optional[str] = Field(None, description='ssl pem 文件内容')
    ssl_key: Optional[str] = Field(None, description='ssl key 文件内容')
    ssl_expire: Optional[int] = Field(None, description='ssl 过期时间')
    deploy_ssl_status: Optional[int] = Field(None, description='部署ssl状态 0未部署 1已部署 2已禁用 3无需要部署')

    pc_template: Optional[str] = Field(None, description='PC刮刮码模板')
    h5_template: Optional[str] = Field(None, description='H5刮刮码模板')

    user_id: Optional[int] = Field(None, description='管理人ID')

    created_at: Annotated[Optional[datetime], Optional[str]] = None
    updated_at: Annotated[Optional[datetime], Optional[str]] = None


class TenantDomainOut(BaseApiOut):
    data: Annotated[TenantDomain, None] = None


class TenantDomainListOut(BaseApiListOut):
    data: Annotated[List[TenantDomain], None] = None
